package zzc.stu.demo.Controller;

import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Description;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zzc.stu.demo.Serve.UserMannagerServe;
import zzc.stu.demo.pojo.UserMannagement;

import javax.annotation.Resource;

@Controller
@Api(description = "通用登录注册模块")
public class UserManagementController {
    @Resource
    UserMannagerServe userMannagerServe;


    @ApiOperation(value = "通用登录API")
    @ResponseBody
    @PostMapping("/zcLoginUtil")
    @Description("信息安全等级：用户自主保护级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "登录id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "password", value = "登陆密码", required = true, dataType = "string", paramType = "query")})
    public String hello(@ApiParam(name = "id", value = "登录id", required = true) String id, String password) {
        if (id.equals("admin") && password.equals("admin")) {
            return "ok";
        }
        return "error";
    }

    @ApiOperation(value = "通用注册API")
    @ResponseBody
    @PostMapping("/zcRegisterUtil")
    @Description("信息安全等级：用户自主保护级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "登录id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "password", value = "登陆密码", required = true, dataType = "string", paramType = "query")})
    public String zhuCe(@ApiParam(name = "id", value = "登录id", required = true) String id, String password) {
        String flag = userMannagerServe.getResult(id,password);
        return flag;
    }
}